		var fhZTreeObj=null;
		var fhclass=null;
		var setting = {
			view: {
				dblClickExpand: false
			},
			data: {
				simpleData: {
					enable: true
				}
			},
			callback: {
				beforeClick: beforeClick,
				onClick: onClick
			}
		};

		var zNodes =[];

		function beforeClick(treeId, treeNode) {
			/*
			var check = (treeNode && !treeNode.isParent);
			if (!check) alert("只能选择城市...");
			return check;
			*/
			return true;
		}
		
		function onClick(e, treeId, treeNode) {
			var zTree =fhZTreeObj;
			nodes = zTree.getSelectedNodes(),
			v = "";
			nodes.sort(function compare(a,b){return a.id-b.id;});
			for (var i=0, l=nodes.length; i<l; i++) {
				v += nodes[i].name + ",";
			}
			if (v.length > 0 ) v = v.substring(0, v.length-1);

			
			var cityObj=$("div[name="+fhclass+"]>div:first>input[name='fhinput1']");			
			cityObj.attr("value", v);
			cityObj.focus();
		}

		function find(str,cha,num){
		    var x=str.indexOf(cha);
		    for(var i=0;i<num;i++){
		        x=str.indexOf(cha,x+1);
		    }
		    return x;
		}


        //获取url中的参数
		    function GetRequest() {
		     var url =  location.href; 
			 //console.log('-------url--------',url);
		     var theRequest ="";
		     if (url.indexOf("&") != -1) 
			 {
		      var k1=find(url,'=',2); 
		      var k2=find(url,'&',2);
			  theRequest =url.substring(k1+1,k2); 
		     }
		       return theRequest;
		    }
	
			
		function fhshowZTree(fhclass,fhdiv)
		{
		    ///菜单数据关键参数
		    //console.log('-------fhclass-------',fhclass);	
            ///var a=GetRequest();			
			var fhmodel=GetRequest();	
		    //console.log('--------model--------',fhmodel);			
			var hidden1=$("div[name="+fhclass+"]>input[name='hidden1']");
            var fhp_field= hidden1.val();			
		    //console.log('--------fhp_field:--------',fhp_field);

			var hidden2=$("div[name="+fhclass+"]>input[name='hidden2']");
            var fhtree_model= hidden2.val();
		    //console.log('-------fhtree_model:--------',fhtree_model);
			

			
			
        $.ajax({
        url: "/web_form_tree/addtree/"+fhtree_model+"/"+fhp_field, async: false, success: function (result) 
		{
            lr = eval('(' + result + ')');					
            zNodes = lr;
			
			///zNodes =zNodes.replace(/</g, '[');
			//zNodes =zNodes.replace(/>/g, ']');					
			fhZTreeObj=$.fn.zTree.init(fhdiv, setting, zNodes);	
          }
        });
			
			
			
		}




		function showMenu(which) {
		    var fhok=$(which).parent().parent();
            fhclass=fhok.attr("name");           
			var fhdiv=$("div[name="+fhclass+"]>ul:first");
            ///初始化树形
            fhshowZTree(fhclass,fhdiv);

		
			var fhinput1=$("div[name="+fhclass+"]>div:first>input[name='fhinput1']");
			var cityObj = fhinput1;		
			var cityOffset =cityObj.offset();
			
			var menuContent = $("div[name="+fhclass+"]:nth-child(2)");			
			menuContent.css({left:cityOffset.left + "px", top:(cityOffset.top-100) + "px"}).slideDown("fast");				
			$("body").bind("mousedown", onBodyDown);
		}
		function hideMenu() {
			var menuContent = $("div[name="+fhclass+"]:nth-child(2)");
			menuContent.fadeOut("fast");			
			$("body").unbind("mousedown", onBodyDown);
		}
		function onBodyDown(event) {
			if (!(event.target.id == "menuBtn" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
				hideMenu();
			}
		}

		$(document).ready(function(){


		});
